﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace WingsOverSpace
{
    class Enemy5 : WingsDrawableGameComponent
    {
        public BoundingSphere BoundingCircle;
        Vector2 Velocity { get; set; }
        Texture2D explosion;
        SpriteBatch spriteBatch;

        public Enemy5(Game g, Vector2 position)
            : base(g)
        {
            Position = position;
            Velocity = new Vector2(0, 0);
            SpriteScaleFactor = 0.5f;
        }

        public override void Draw(GameTime gameTime)
        {
            // Basically, this is a bunch of rectangles containing the parts of the sprite that we want to draw, because the sprites are in spritesheets so the animations will be implemented by changing rectangles.
            // Currently, I only have the program draw the fullHealth ship, but once we implement the health system we'll have to switch between rectangles, and when the player dies we'll also have to use the explosion
            // rectangles for that animation.

            Vector2 offset = new Vector2(sprite.Width / 2, sprite.Height / 2);
            Rectangle fullHealth = new Rectangle(0, 500, sprite.Width, sprite.Height / 6);
            Rectangle startExplosion = new Rectangle(0, 0, explosion.Width / 3, explosion.Height);
            Rectangle explosionContinues = new Rectangle(500, 0, explosion.Width / 3, explosion.Height);
            Rectangle endExplosion = new Rectangle(1000, 0, explosion.Width / 3, explosion.Height);

            spriteBatch.Begin();
            spriteBatch.Draw(sprite, Position - offset, null, Color.White, 0f, new Vector2(0, 0), SpriteScaleFactor, SpriteEffects.None, 0.05f);
            spriteBatch.End();
        }

        protected override void LoadContent()
        {
            sprite = Game.Content.Load<Texture2D>("EnemyShip005");
            explosion = Game.Content.Load<Texture2D>("EnemyShipExplosion");
            spriteBatch = new SpriteBatch(Game.GraphicsDevice);

            Vector3 LeftBound = new Vector3((sprite.Bounds.Center.X - sprite.Bounds.Left) * 1 / 2, sprite.Bounds.Center.Y, 0);
            Vector3 RightBound = new Vector3((sprite.Bounds.Right - sprite.Bounds.Center.X) * 1 / 2, sprite.Bounds.Center.Y, 0);
            List<Vector3> Bounds = new List<Vector3>(2);
            Bounds.Add(LeftBound);
            Bounds.Add(RightBound);
            BoundingCircle = BoundingSphere.CreateFromPoints(Bounds);
            base.LoadContent();
        }

        public override void Update(GameTime gameTime)
        {
            KeyboardState k = Keyboard.GetState();
            float elapsedSeconds = (float)gameTime.ElapsedGameTime.TotalSeconds;

            Vector2 xMovementVector = new Vector2(5, 0);
            Vector2 yMovementVector = new Vector2(0, 5);

            BoundingCircle.Center = new Vector3(Position.X, Position.Y, 0);
            base.Update(gameTime);

        }

    }
}